use :: libc;
extern "C" {
    fn free(_: *mut libc::c_void);
    fn strcmp(_: *const i8, _: *const i8) -> i32;
    fn xcalloc(_: size_t, _: size_t) -> *mut libc::c_void;
    fn xasprintf(_: *mut *mut i8, _: *const i8, _: ...) -> i32;
    fn utf8_stravis(_: *mut *mut i8, _: *const i8, _: i32) -> i32;
}
pub type __u_int = u32;
pub type u_int = __u_int;
pub type size_t = u64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks {
    pub next_inner: u_int,
    pub by_inner: hyperlinks_by_inner_tree,
    pub by_uri: hyperlinks_by_uri_tree,
    pub references: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_by_uri_tree {
    pub rbh_root: *mut hyperlinks_uri,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_uri {
    pub tree: *mut hyperlinks,
    pub inner: u_int,
    pub internal_id: *const i8,
    pub external_id: *const i8,
    pub uri: *const i8,
    pub list_entry: C2RustUnnamed_1,
    pub by_inner_entry: C2RustUnnamed_0,
    pub by_uri_entry: C2RustUnnamed,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed {
    pub rbe_left: *mut hyperlinks_uri,
    pub rbe_right: *mut hyperlinks_uri,
    pub rbe_parent: *mut hyperlinks_uri,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_0 {
    pub rbe_left: *mut hyperlinks_uri,
    pub rbe_right: *mut hyperlinks_uri,
    pub rbe_parent: *mut hyperlinks_uri,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    pub tqe_next: *mut hyperlinks_uri,
    pub tqe_prev: *mut *mut hyperlinks_uri,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_by_inner_tree {
    pub rbh_root: *mut hyperlinks_uri,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_list {
    pub tqh_first: *mut hyperlinks_uri,
    pub tqh_last: *mut *mut hyperlinks_uri,
}
static mut hyperlinks_next_external_id: i64 = 1 as i32 as i64;
static mut global_hyperlinks_count: u_int = 0;
static mut global_hyperlinks: hyperlinks_list = hyperlinks_list {
    tqh_first: 0 as *const hyperlinks_uri as *mut hyperlinks_uri,
    tqh_last: 0 as *const *mut hyperlinks_uri as *mut *mut hyperlinks_uri,
};
extern "C" fn hyperlinks_by_uri_cmp(
    mut left: *mut hyperlinks_uri,
    mut right: *mut hyperlinks_uri,
) -> i32 {
    let mut r: i32 = 0;
    if (unsafe { *(*left).internal_id }) as i32 == '\0' as i32
        || (unsafe { *(*right).internal_id }) as i32 == '\0' as i32
    {
        if (unsafe { *(*left).internal_id }) as i32 != '\0' as i32 {
            return -(1 as i32);
        }
        if (unsafe { *(*right).internal_id }) as i32 != '\0' as i32 {
            return 1 as i32;
        }
        return (unsafe { (*left).inner }).wrapping_sub(unsafe { (*right).inner }) as i32;
    }
    r = unsafe { strcmp((*left).internal_id, (*right).internal_id) };
    if r != 0 as i32 {
        return r;
    }
    return unsafe { strcmp((*left).uri, (*right).uri) };
}
extern "C" fn hyperlinks_by_uri_tree_RB_INSERT_COLOR(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) {
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut gparent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    loop {
        parent = unsafe { (*elm).by_uri_entry.rbe_parent };
        if parent.is_null() || (unsafe { (*parent).by_uri_entry.rbe_color }) != 1 as i32 {
            break;
        }
        gparent = unsafe { (*parent).by_uri_entry.rbe_parent };
        if parent == (unsafe { (*gparent).by_uri_entry.rbe_left }) {
            tmp = unsafe { (*gparent).by_uri_entry.rbe_right };
            if !tmp.is_null() && (unsafe { (*tmp).by_uri_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_uri_entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).by_uri_entry.rbe_right }) == elm {
                    tmp = unsafe { (*parent).by_uri_entry.rbe_right };
                    (unsafe { (*parent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left });
                    if !(unsafe { (*parent).by_uri_entry.rbe_right }).is_null() {
                        (unsafe {
                            (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = parent
                        });
                    }
                    (unsafe { (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent });
                    if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                        if parent
                            == (unsafe {
                                (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left
                            })
                        {
                            (unsafe {
                                (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                            });
                        } else {
                            (unsafe {
                                (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).by_uri_entry.rbe_left = parent });
                    (unsafe { (*parent).by_uri_entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_uri_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).by_uri_entry.rbe_left };
                (unsafe { (*gparent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right });
                if !(unsafe { (*gparent).by_uri_entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = gparent });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_parent = (*gparent).by_uri_entry.rbe_parent });
                if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                    if gparent
                        == (unsafe { (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                    {
                        (unsafe {
                            (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_right = gparent });
                (unsafe { (*gparent).by_uri_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
            }
        } else {
            tmp = unsafe { (*gparent).by_uri_entry.rbe_left };
            if !tmp.is_null() && (unsafe { (*tmp).by_uri_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_uri_entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).by_uri_entry.rbe_left }) == elm {
                    tmp = unsafe { (*parent).by_uri_entry.rbe_left };
                    (unsafe { (*parent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right });
                    if !(unsafe { (*parent).by_uri_entry.rbe_left }).is_null() {
                        (unsafe {
                            (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = parent
                        });
                    }
                    (unsafe { (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent });
                    if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                        if parent
                            == (unsafe {
                                (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left
                            })
                        {
                            (unsafe {
                                (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                            });
                        } else {
                            (unsafe {
                                (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).by_uri_entry.rbe_right = parent });
                    (unsafe { (*parent).by_uri_entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_uri_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).by_uri_entry.rbe_right };
                (unsafe { (*gparent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left });
                if !(unsafe { (*gparent).by_uri_entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = gparent });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_parent = (*gparent).by_uri_entry.rbe_parent });
                if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                    if gparent
                        == (unsafe { (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                    {
                        (unsafe {
                            (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_left = gparent });
                (unsafe { (*gparent).by_uri_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
            }
        }
    }
    (unsafe { (*(*head).rbh_root).by_uri_entry.rbe_color = 0 as i32 });
}
extern "C" fn hyperlinks_by_uri_tree_RB_FIND(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = unsafe { (*head).rbh_root };
    let mut comp: i32 = 0;
    while !tmp.is_null() {
        comp = hyperlinks_by_uri_cmp(elm, tmp);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).by_uri_entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).by_uri_entry.rbe_right };
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<hyperlinks_uri>();
}
extern "C" fn hyperlinks_by_uri_tree_RB_REMOVE(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut current_block: u64;
    let mut child: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut old: *mut hyperlinks_uri = elm;
    let mut color: i32 = 0;
    if (unsafe { (*elm).by_uri_entry.rbe_left }).is_null() {
        child = unsafe { (*elm).by_uri_entry.rbe_right };
        current_block = 7245201122033322888;
    } else if (unsafe { (*elm).by_uri_entry.rbe_right }).is_null() {
        child = unsafe { (*elm).by_uri_entry.rbe_left };
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
        elm = unsafe { (*elm).by_uri_entry.rbe_right };
        loop {
            left = unsafe { (*elm).by_uri_entry.rbe_left };
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = unsafe { (*elm).by_uri_entry.rbe_right };
        parent = unsafe { (*elm).by_uri_entry.rbe_parent };
        color = unsafe { (*elm).by_uri_entry.rbe_color };
        if !child.is_null() {
            (unsafe { (*child).by_uri_entry.rbe_parent = parent });
        }
        if !parent.is_null() {
            if (unsafe { (*parent).by_uri_entry.rbe_left }) == elm {
                (unsafe { (*parent).by_uri_entry.rbe_left = child });
            } else {
                (unsafe { (*parent).by_uri_entry.rbe_right = child });
            }
        } else {
            (unsafe { (*head).rbh_root = child });
        }
        if (unsafe { (*elm).by_uri_entry.rbe_parent }) == old {
            parent = elm;
        }
        (unsafe { (*elm).by_uri_entry = (*old).by_uri_entry });
        if !(unsafe { (*old).by_uri_entry.rbe_parent }).is_null() {
            if (unsafe { (*(*old).by_uri_entry.rbe_parent).by_uri_entry.rbe_left }) == old {
                (unsafe { (*(*old).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = elm });
            } else {
                (unsafe { (*(*old).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = elm });
            }
        } else {
            (unsafe { (*head).rbh_root = elm });
        }
        (unsafe { (*(*old).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = elm });
        if !(unsafe { (*old).by_uri_entry.rbe_right }).is_null() {
            (unsafe { (*(*old).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = elm });
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = unsafe { (*left).by_uri_entry.rbe_parent };
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 3443566586990830109;
    }
    match current_block {
        7245201122033322888 => {
            parent = unsafe { (*elm).by_uri_entry.rbe_parent };
            color = unsafe { (*elm).by_uri_entry.rbe_color };
            if !child.is_null() {
                (unsafe { (*child).by_uri_entry.rbe_parent = parent });
            }
            if !parent.is_null() {
                if (unsafe { (*parent).by_uri_entry.rbe_left }) == elm {
                    (unsafe { (*parent).by_uri_entry.rbe_left = child });
                } else {
                    (unsafe { (*parent).by_uri_entry.rbe_right = child });
                }
            } else {
                (unsafe { (*head).rbh_root = child });
            }
        }
        _ => {}
    }
    if color == 0 as i32 {
        hyperlinks_by_uri_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
extern "C" fn hyperlinks_by_uri_tree_RB_REMOVE_COLOR(
    mut head: *mut hyperlinks_by_uri_tree,
    mut parent: *mut hyperlinks_uri,
    mut elm: *mut hyperlinks_uri,
) {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    while (elm.is_null() || (unsafe { (*elm).by_uri_entry.rbe_color }) == 0 as i32)
        && elm != (unsafe { (*head).rbh_root })
    {
        if (unsafe { (*parent).by_uri_entry.rbe_left }) == elm {
            tmp = unsafe { (*parent).by_uri_entry.rbe_right };
            if (unsafe { (*tmp).by_uri_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_uri_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).by_uri_entry.rbe_right };
                (unsafe { (*parent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left });
                if !(unsafe { (*parent).by_uri_entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent });
                if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe { (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                    {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_left = parent });
                (unsafe { (*parent).by_uri_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).by_uri_entry.rbe_right };
            }
            if ((unsafe { (*tmp).by_uri_entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color }) == 0 as i32)
                && ((unsafe { (*tmp).by_uri_entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color })
                        == 0 as i32)
            {
                (unsafe { (*tmp).by_uri_entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).by_uri_entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).by_uri_entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color })
                        == 0 as i32
                {
                    let mut oleft: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oleft = unsafe { (*tmp).by_uri_entry.rbe_left };
                    if !oleft.is_null() {
                        (unsafe { (*oleft).by_uri_entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).by_uri_entry.rbe_color = 1 as i32 });
                    oleft = unsafe { (*tmp).by_uri_entry.rbe_left };
                    (unsafe { (*tmp).by_uri_entry.rbe_left = (*oleft).by_uri_entry.rbe_right });
                    if !(unsafe { (*tmp).by_uri_entry.rbe_left }).is_null() {
                        (unsafe {
                            (*(*oleft).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = tmp
                        });
                    }
                    (unsafe { (*oleft).by_uri_entry.rbe_parent = (*tmp).by_uri_entry.rbe_parent });
                    if !(unsafe { (*oleft).by_uri_entry.rbe_parent }).is_null() {
                        if tmp
                            == (unsafe { (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                        {
                            (unsafe {
                                (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = oleft
                            });
                        } else {
                            (unsafe {
                                (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = oleft
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oleft });
                    }
                    (unsafe { (*oleft).by_uri_entry.rbe_right = tmp });
                    (unsafe { (*tmp).by_uri_entry.rbe_parent = oleft });
                    let _ = !(unsafe { (*oleft).by_uri_entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).by_uri_entry.rbe_right };
                }
                (unsafe { (*tmp).by_uri_entry.rbe_color = (*parent).by_uri_entry.rbe_color });
                (unsafe { (*parent).by_uri_entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).by_uri_entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color = 0 as i32 });
                }
                tmp = unsafe { (*parent).by_uri_entry.rbe_right };
                (unsafe { (*parent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left });
                if !(unsafe { (*parent).by_uri_entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent });
                if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe { (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                    {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_left = parent });
                (unsafe { (*parent).by_uri_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        } else {
            tmp = unsafe { (*parent).by_uri_entry.rbe_left };
            if (unsafe { (*tmp).by_uri_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_uri_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_uri_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).by_uri_entry.rbe_left };
                (unsafe { (*parent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right });
                if !(unsafe { (*parent).by_uri_entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent });
                if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe { (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                    {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_right = parent });
                (unsafe { (*parent).by_uri_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).by_uri_entry.rbe_left };
            }
            if ((unsafe { (*tmp).by_uri_entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color }) == 0 as i32)
                && ((unsafe { (*tmp).by_uri_entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color })
                        == 0 as i32)
            {
                (unsafe { (*tmp).by_uri_entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).by_uri_entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).by_uri_entry.rbe_left }).is_null()
                    || (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color })
                        == 0 as i32
                {
                    let mut oright: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oright = unsafe { (*tmp).by_uri_entry.rbe_right };
                    if !oright.is_null() {
                        (unsafe { (*oright).by_uri_entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).by_uri_entry.rbe_color = 1 as i32 });
                    oright = unsafe { (*tmp).by_uri_entry.rbe_right };
                    (unsafe { (*tmp).by_uri_entry.rbe_right = (*oright).by_uri_entry.rbe_left });
                    if !(unsafe { (*tmp).by_uri_entry.rbe_right }).is_null() {
                        (unsafe {
                            (*(*oright).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = tmp
                        });
                    }
                    (unsafe { (*oright).by_uri_entry.rbe_parent = (*tmp).by_uri_entry.rbe_parent });
                    if !(unsafe { (*oright).by_uri_entry.rbe_parent }).is_null() {
                        if tmp
                            == (unsafe { (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                        {
                            (unsafe {
                                (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = oright
                            });
                        } else {
                            (unsafe {
                                (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = oright
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oright });
                    }
                    (unsafe { (*oright).by_uri_entry.rbe_left = tmp });
                    (unsafe { (*tmp).by_uri_entry.rbe_parent = oright });
                    let _ = !(unsafe { (*oright).by_uri_entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).by_uri_entry.rbe_left };
                }
                (unsafe { (*tmp).by_uri_entry.rbe_color = (*parent).by_uri_entry.rbe_color });
                (unsafe { (*parent).by_uri_entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).by_uri_entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color = 0 as i32 });
                }
                tmp = unsafe { (*parent).by_uri_entry.rbe_left };
                (unsafe { (*parent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right });
                if !(unsafe { (*parent).by_uri_entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent });
                if !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe { (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left })
                    {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_uri_entry.rbe_right = parent });
                (unsafe { (*parent).by_uri_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_uri_entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        }
    }
    if !elm.is_null() {
        (unsafe { (*elm).by_uri_entry.rbe_color = 0 as i32 });
    }
}
extern "C" fn hyperlinks_by_uri_tree_RB_INSERT(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut comp: i32 = 0 as i32;
    tmp = unsafe { (*head).rbh_root };
    while !tmp.is_null() {
        parent = tmp;
        comp = hyperlinks_by_uri_cmp(elm, parent);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).by_uri_entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).by_uri_entry.rbe_right };
        } else {
            return tmp;
        }
    }
    (unsafe { (*elm).by_uri_entry.rbe_parent = parent });
    (unsafe { (*elm).by_uri_entry.rbe_right = std::ptr::null_mut::<hyperlinks_uri>() });
    (unsafe { (*elm).by_uri_entry.rbe_left = (*elm).by_uri_entry.rbe_right });
    (unsafe { (*elm).by_uri_entry.rbe_color = 1 as i32 });
    if !parent.is_null() {
        if comp < 0 as i32 {
            (unsafe { (*parent).by_uri_entry.rbe_left = elm });
        } else {
            (unsafe { (*parent).by_uri_entry.rbe_right = elm });
        }
    } else {
        (unsafe { (*head).rbh_root = elm });
    }
    hyperlinks_by_uri_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<hyperlinks_uri>();
}
extern "C" fn hyperlinks_by_inner_cmp(
    mut left: *mut hyperlinks_uri,
    mut right: *mut hyperlinks_uri,
) -> i32 {
    return (unsafe { (*left).inner }).wrapping_sub(unsafe { (*right).inner }) as i32;
}
extern "C" fn hyperlinks_by_inner_tree_RB_NEXT(
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    if !(unsafe { (*elm).by_inner_entry.rbe_right }).is_null() {
        elm = unsafe { (*elm).by_inner_entry.rbe_right };
        while !(unsafe { (*elm).by_inner_entry.rbe_left }).is_null() {
            elm = unsafe { (*elm).by_inner_entry.rbe_left };
        }
    } else if !(unsafe { (*elm).by_inner_entry.rbe_parent }).is_null()
        && elm == (unsafe { (*(*elm).by_inner_entry.rbe_parent).by_inner_entry.rbe_left })
    {
        elm = unsafe { (*elm).by_inner_entry.rbe_parent };
    } else {
        while !(unsafe { (*elm).by_inner_entry.rbe_parent }).is_null()
            && elm == (unsafe { (*(*elm).by_inner_entry.rbe_parent).by_inner_entry.rbe_right })
        {
            elm = unsafe { (*elm).by_inner_entry.rbe_parent };
        }
        elm = unsafe { (*elm).by_inner_entry.rbe_parent };
    }
    return elm;
}
extern "C" fn hyperlinks_by_inner_tree_RB_INSERT_COLOR(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) {
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut gparent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    loop {
        parent = unsafe { (*elm).by_inner_entry.rbe_parent };
        if parent.is_null() || (unsafe { (*parent).by_inner_entry.rbe_color }) != 1 as i32 {
            break;
        }
        gparent = unsafe { (*parent).by_inner_entry.rbe_parent };
        if parent == (unsafe { (*gparent).by_inner_entry.rbe_left }) {
            tmp = unsafe { (*gparent).by_inner_entry.rbe_right };
            if !tmp.is_null() && (unsafe { (*tmp).by_inner_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_inner_entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).by_inner_entry.rbe_right }) == elm {
                    tmp = unsafe { (*parent).by_inner_entry.rbe_right };
                    (unsafe {
                        (*parent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left
                    });
                    if !(unsafe { (*parent).by_inner_entry.rbe_right }).is_null() {
                        (unsafe {
                            (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = parent
                        });
                    }
                    (unsafe {
                        (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent
                    });
                    if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                        if parent
                            == (unsafe {
                                (*(*parent).by_inner_entry.rbe_parent)
                                    .by_inner_entry
                                    .rbe_left
                            })
                        {
                            (unsafe {
                                (*(*parent).by_inner_entry.rbe_parent)
                                    .by_inner_entry
                                    .rbe_left = tmp
                            });
                        } else {
                            (unsafe {
                                (*(*parent).by_inner_entry.rbe_parent)
                                    .by_inner_entry
                                    .rbe_right = tmp
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).by_inner_entry.rbe_left = parent });
                    (unsafe { (*parent).by_inner_entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_inner_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).by_inner_entry.rbe_left };
                (unsafe { (*gparent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right });
                if !(unsafe { (*gparent).by_inner_entry.rbe_left }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = gparent
                    });
                }
                (unsafe {
                    (*tmp).by_inner_entry.rbe_parent = (*gparent).by_inner_entry.rbe_parent
                });
                if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                    if gparent
                        == (unsafe {
                            (*(*gparent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        })
                    {
                        (unsafe {
                            (*(*gparent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*gparent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_right = gparent });
                (unsafe { (*gparent).by_inner_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
            }
        } else {
            tmp = unsafe { (*gparent).by_inner_entry.rbe_left };
            if !tmp.is_null() && (unsafe { (*tmp).by_inner_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_inner_entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).by_inner_entry.rbe_left }) == elm {
                    tmp = unsafe { (*parent).by_inner_entry.rbe_left };
                    (unsafe {
                        (*parent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right
                    });
                    if !(unsafe { (*parent).by_inner_entry.rbe_left }).is_null() {
                        (unsafe {
                            (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = parent
                        });
                    }
                    (unsafe {
                        (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent
                    });
                    if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                        if parent
                            == (unsafe {
                                (*(*parent).by_inner_entry.rbe_parent)
                                    .by_inner_entry
                                    .rbe_left
                            })
                        {
                            (unsafe {
                                (*(*parent).by_inner_entry.rbe_parent)
                                    .by_inner_entry
                                    .rbe_left = tmp
                            });
                        } else {
                            (unsafe {
                                (*(*parent).by_inner_entry.rbe_parent)
                                    .by_inner_entry
                                    .rbe_right = tmp
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).by_inner_entry.rbe_right = parent });
                    (unsafe { (*parent).by_inner_entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).by_inner_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).by_inner_entry.rbe_right };
                (unsafe { (*gparent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left });
                if !(unsafe { (*gparent).by_inner_entry.rbe_right }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = gparent
                    });
                }
                (unsafe {
                    (*tmp).by_inner_entry.rbe_parent = (*gparent).by_inner_entry.rbe_parent
                });
                if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                    if gparent
                        == (unsafe {
                            (*(*gparent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        })
                    {
                        (unsafe {
                            (*(*gparent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*gparent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_left = gparent });
                (unsafe { (*gparent).by_inner_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
            }
        }
    }
    (unsafe { (*(*head).rbh_root).by_inner_entry.rbe_color = 0 as i32 });
}
extern "C" fn hyperlinks_by_inner_tree_RB_MINMAX(
    mut head: *mut hyperlinks_by_inner_tree,
    mut val: i32,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = unsafe { (*head).rbh_root };
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    while !tmp.is_null() {
        parent = tmp;
        if val < 0 as i32 {
            tmp = unsafe { (*tmp).by_inner_entry.rbe_left };
        } else {
            tmp = unsafe { (*tmp).by_inner_entry.rbe_right };
        }
    }
    return parent;
}
extern "C" fn hyperlinks_by_inner_tree_RB_INSERT(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut comp: i32 = 0 as i32;
    tmp = unsafe { (*head).rbh_root };
    while !tmp.is_null() {
        parent = tmp;
        comp = hyperlinks_by_inner_cmp(elm, parent);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).by_inner_entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).by_inner_entry.rbe_right };
        } else {
            return tmp;
        }
    }
    (unsafe { (*elm).by_inner_entry.rbe_parent = parent });
    (unsafe { (*elm).by_inner_entry.rbe_right = std::ptr::null_mut::<hyperlinks_uri>() });
    (unsafe { (*elm).by_inner_entry.rbe_left = (*elm).by_inner_entry.rbe_right });
    (unsafe { (*elm).by_inner_entry.rbe_color = 1 as i32 });
    if !parent.is_null() {
        if comp < 0 as i32 {
            (unsafe { (*parent).by_inner_entry.rbe_left = elm });
        } else {
            (unsafe { (*parent).by_inner_entry.rbe_right = elm });
        }
    } else {
        (unsafe { (*head).rbh_root = elm });
    }
    hyperlinks_by_inner_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<hyperlinks_uri>();
}
extern "C" fn hyperlinks_by_inner_tree_RB_REMOVE_COLOR(
    mut head: *mut hyperlinks_by_inner_tree,
    mut parent: *mut hyperlinks_uri,
    mut elm: *mut hyperlinks_uri,
) {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    while (elm.is_null() || (unsafe { (*elm).by_inner_entry.rbe_color }) == 0 as i32)
        && elm != (unsafe { (*head).rbh_root })
    {
        if (unsafe { (*parent).by_inner_entry.rbe_left }) == elm {
            tmp = unsafe { (*parent).by_inner_entry.rbe_right };
            if (unsafe { (*tmp).by_inner_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_inner_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).by_inner_entry.rbe_right };
                (unsafe { (*parent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left });
                if !(unsafe { (*parent).by_inner_entry.rbe_right }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = parent
                    });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent });
                if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        })
                    {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_left = parent });
                (unsafe { (*parent).by_inner_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).by_inner_entry.rbe_right };
            }
            if ((unsafe { (*tmp).by_inner_entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color })
                    == 0 as i32)
                && ((unsafe { (*tmp).by_inner_entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color })
                        == 0 as i32)
            {
                (unsafe { (*tmp).by_inner_entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).by_inner_entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).by_inner_entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color })
                        == 0 as i32
                {
                    let mut oleft: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oleft = unsafe { (*tmp).by_inner_entry.rbe_left };
                    if !oleft.is_null() {
                        (unsafe { (*oleft).by_inner_entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).by_inner_entry.rbe_color = 1 as i32 });
                    oleft = unsafe { (*tmp).by_inner_entry.rbe_left };
                    (unsafe { (*tmp).by_inner_entry.rbe_left = (*oleft).by_inner_entry.rbe_right });
                    if !(unsafe { (*tmp).by_inner_entry.rbe_left }).is_null() {
                        (unsafe {
                            (*(*oleft).by_inner_entry.rbe_right)
                                .by_inner_entry
                                .rbe_parent = tmp
                        });
                    }
                    (unsafe {
                        (*oleft).by_inner_entry.rbe_parent = (*tmp).by_inner_entry.rbe_parent
                    });
                    if !(unsafe { (*oleft).by_inner_entry.rbe_parent }).is_null() {
                        if tmp
                            == (unsafe {
                                (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left
                            })
                        {
                            (unsafe {
                                (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left = oleft
                            });
                        } else {
                            (unsafe {
                                (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_right = oleft
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oleft });
                    }
                    (unsafe { (*oleft).by_inner_entry.rbe_right = tmp });
                    (unsafe { (*tmp).by_inner_entry.rbe_parent = oleft });
                    let _ = !(unsafe { (*oleft).by_inner_entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).by_inner_entry.rbe_right };
                }
                (unsafe { (*tmp).by_inner_entry.rbe_color = (*parent).by_inner_entry.rbe_color });
                (unsafe { (*parent).by_inner_entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).by_inner_entry.rbe_right }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color = 0 as i32
                    });
                }
                tmp = unsafe { (*parent).by_inner_entry.rbe_right };
                (unsafe { (*parent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left });
                if !(unsafe { (*parent).by_inner_entry.rbe_right }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = parent
                    });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent });
                if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        })
                    {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_left = parent });
                (unsafe { (*parent).by_inner_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        } else {
            tmp = unsafe { (*parent).by_inner_entry.rbe_left };
            if (unsafe { (*tmp).by_inner_entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).by_inner_entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).by_inner_entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).by_inner_entry.rbe_left };
                (unsafe { (*parent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right });
                if !(unsafe { (*parent).by_inner_entry.rbe_left }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = parent
                    });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent });
                if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        })
                    {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_right = parent });
                (unsafe { (*parent).by_inner_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).by_inner_entry.rbe_left };
            }
            if ((unsafe { (*tmp).by_inner_entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color })
                    == 0 as i32)
                && ((unsafe { (*tmp).by_inner_entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color })
                        == 0 as i32)
            {
                (unsafe { (*tmp).by_inner_entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).by_inner_entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).by_inner_entry.rbe_left }).is_null()
                    || (unsafe { (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color })
                        == 0 as i32
                {
                    let mut oright: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oright = unsafe { (*tmp).by_inner_entry.rbe_right };
                    if !oright.is_null() {
                        (unsafe { (*oright).by_inner_entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).by_inner_entry.rbe_color = 1 as i32 });
                    oright = unsafe { (*tmp).by_inner_entry.rbe_right };
                    (unsafe {
                        (*tmp).by_inner_entry.rbe_right = (*oright).by_inner_entry.rbe_left
                    });
                    if !(unsafe { (*tmp).by_inner_entry.rbe_right }).is_null() {
                        (unsafe {
                            (*(*oright).by_inner_entry.rbe_left)
                                .by_inner_entry
                                .rbe_parent = tmp
                        });
                    }
                    (unsafe {
                        (*oright).by_inner_entry.rbe_parent = (*tmp).by_inner_entry.rbe_parent
                    });
                    if !(unsafe { (*oright).by_inner_entry.rbe_parent }).is_null() {
                        if tmp
                            == (unsafe {
                                (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left
                            })
                        {
                            (unsafe {
                                (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left = oright
                            });
                        } else {
                            (unsafe {
                                (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_right =
                                    oright
                            });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oright });
                    }
                    (unsafe { (*oright).by_inner_entry.rbe_left = tmp });
                    (unsafe { (*tmp).by_inner_entry.rbe_parent = oright });
                    let _ = !(unsafe { (*oright).by_inner_entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).by_inner_entry.rbe_left };
                }
                (unsafe { (*tmp).by_inner_entry.rbe_color = (*parent).by_inner_entry.rbe_color });
                (unsafe { (*parent).by_inner_entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).by_inner_entry.rbe_left }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color = 0 as i32
                    });
                }
                tmp = unsafe { (*parent).by_inner_entry.rbe_left };
                (unsafe { (*parent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right });
                if !(unsafe { (*parent).by_inner_entry.rbe_left }).is_null() {
                    (unsafe {
                        (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = parent
                    });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent });
                if !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null() {
                    if parent
                        == (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        })
                    {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp
                        });
                    } else {
                        (unsafe {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp
                        });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).by_inner_entry.rbe_right = parent });
                (unsafe { (*parent).by_inner_entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).by_inner_entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        }
    }
    if !elm.is_null() {
        (unsafe { (*elm).by_inner_entry.rbe_color = 0 as i32 });
    }
}
extern "C" fn hyperlinks_by_inner_tree_RB_REMOVE(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut current_block: u64;
    let mut child: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut old: *mut hyperlinks_uri = elm;
    let mut color: i32 = 0;
    if (unsafe { (*elm).by_inner_entry.rbe_left }).is_null() {
        child = unsafe { (*elm).by_inner_entry.rbe_right };
        current_block = 7245201122033322888;
    } else if (unsafe { (*elm).by_inner_entry.rbe_right }).is_null() {
        child = unsafe { (*elm).by_inner_entry.rbe_left };
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
        elm = unsafe { (*elm).by_inner_entry.rbe_right };
        loop {
            left = unsafe { (*elm).by_inner_entry.rbe_left };
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = unsafe { (*elm).by_inner_entry.rbe_right };
        parent = unsafe { (*elm).by_inner_entry.rbe_parent };
        color = unsafe { (*elm).by_inner_entry.rbe_color };
        if !child.is_null() {
            (unsafe { (*child).by_inner_entry.rbe_parent = parent });
        }
        if !parent.is_null() {
            if (unsafe { (*parent).by_inner_entry.rbe_left }) == elm {
                (unsafe { (*parent).by_inner_entry.rbe_left = child });
            } else {
                (unsafe { (*parent).by_inner_entry.rbe_right = child });
            }
        } else {
            (unsafe { (*head).rbh_root = child });
        }
        if (unsafe { (*elm).by_inner_entry.rbe_parent }) == old {
            parent = elm;
        }
        (unsafe { (*elm).by_inner_entry = (*old).by_inner_entry });
        if !(unsafe { (*old).by_inner_entry.rbe_parent }).is_null() {
            if (unsafe { (*(*old).by_inner_entry.rbe_parent).by_inner_entry.rbe_left }) == old {
                (unsafe { (*(*old).by_inner_entry.rbe_parent).by_inner_entry.rbe_left = elm });
            } else {
                (unsafe { (*(*old).by_inner_entry.rbe_parent).by_inner_entry.rbe_right = elm });
            }
        } else {
            (unsafe { (*head).rbh_root = elm });
        }
        (unsafe { (*(*old).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = elm });
        if !(unsafe { (*old).by_inner_entry.rbe_right }).is_null() {
            (unsafe { (*(*old).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = elm });
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = unsafe { (*left).by_inner_entry.rbe_parent };
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 11121321688420496970;
    }
    match current_block {
        7245201122033322888 => {
            parent = unsafe { (*elm).by_inner_entry.rbe_parent };
            color = unsafe { (*elm).by_inner_entry.rbe_color };
            if !child.is_null() {
                (unsafe { (*child).by_inner_entry.rbe_parent = parent });
            }
            if !parent.is_null() {
                if (unsafe { (*parent).by_inner_entry.rbe_left }) == elm {
                    (unsafe { (*parent).by_inner_entry.rbe_left = child });
                } else {
                    (unsafe { (*parent).by_inner_entry.rbe_right = child });
                }
            } else {
                (unsafe { (*head).rbh_root = child });
            }
        }
        _ => {}
    }
    if color == 0 as i32 {
        hyperlinks_by_inner_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
extern "C" fn hyperlinks_by_inner_tree_RB_FIND(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = unsafe { (*head).rbh_root };
    let mut comp: i32 = 0;
    while !tmp.is_null() {
        comp = hyperlinks_by_inner_cmp(elm, tmp);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).by_inner_entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).by_inner_entry.rbe_right };
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<hyperlinks_uri>();
}
extern "C" fn hyperlinks_remove(mut hlu: *mut hyperlinks_uri) {
    let mut hl: *mut hyperlinks = unsafe { (*hlu).tree };
    if !(unsafe { (*hlu).list_entry.tqe_next }).is_null() {
        (unsafe { (*(*hlu).list_entry.tqe_next).list_entry.tqe_prev = (*hlu).list_entry.tqe_prev });
    } else {
        (unsafe { global_hyperlinks.tqh_last = (*hlu).list_entry.tqe_prev });
    }
    (unsafe { *(*hlu).list_entry.tqe_prev = (*hlu).list_entry.tqe_next });
    (unsafe { global_hyperlinks_count = global_hyperlinks_count.wrapping_sub(1) });
    hyperlinks_by_inner_tree_RB_REMOVE(unsafe { &mut (*hl).by_inner }, hlu);
    hyperlinks_by_uri_tree_RB_REMOVE(unsafe { &mut (*hl).by_uri }, hlu);
    (unsafe { free((*hlu).internal_id as *mut libc::c_void) });
    (unsafe { free((*hlu).external_id as *mut libc::c_void) });
    (unsafe { free((*hlu).uri as *mut libc::c_void) });
    (unsafe { free(hlu as *mut libc::c_void) });
}
#[no_mangle]
pub extern "C" fn hyperlinks_put(
    mut hl: *mut hyperlinks,
    mut uri_in: *const i8,
    mut internal_id_in: *const i8,
) -> u_int {
    let mut find: hyperlinks_uri = hyperlinks_uri {
        tree: std::ptr::null_mut::<hyperlinks>(),
        inner: 0,
        internal_id: std::ptr::null::<i8>(),
        external_id: std::ptr::null::<i8>(),
        uri: std::ptr::null::<i8>(),
        list_entry: C2RustUnnamed_1 {
            tqe_next: std::ptr::null_mut::<hyperlinks_uri>(),
            tqe_prev: std::ptr::null_mut::<*mut hyperlinks_uri>(),
        },
        by_inner_entry: C2RustUnnamed_0 {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
        by_uri_entry: C2RustUnnamed {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
    };
    let mut hlu: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut uri: *mut i8 = std::ptr::null_mut::<i8>();
    let mut internal_id: *mut i8 = std::ptr::null_mut::<i8>();
    let mut external_id: *mut i8 = std::ptr::null_mut::<i8>();
    if internal_id_in.is_null() {
        internal_id_in = b"\0" as *const u8 as *const i8;
    }
    (unsafe { utf8_stravis(&mut uri, uri_in, 0x1 as i32 | 0x2 as i32) });
    (unsafe { utf8_stravis(&mut internal_id, internal_id_in, 0x1 as i32 | 0x2 as i32) });
    if (unsafe { *internal_id_in }) as i32 != '\0' as i32 {
        find.uri = uri;
        find.internal_id = internal_id;
        hlu = hyperlinks_by_uri_tree_RB_FIND(unsafe { &mut (*hl).by_uri }, &mut find);
        if !hlu.is_null() {
            (unsafe { free(uri as *mut libc::c_void) });
            (unsafe { free(internal_id as *mut libc::c_void) });
            return unsafe { (*hlu).inner };
        }
    }
    let fresh0 = unsafe { hyperlinks_next_external_id };
    (unsafe { hyperlinks_next_external_id = hyperlinks_next_external_id + 1 });
    (unsafe {
        xasprintf(
            &mut external_id as *mut *mut i8,
            b"tmux%llX\0" as *const u8 as *const i8,
            fresh0,
        )
    });
    hlu = (unsafe {
        xcalloc(
            1 as i32 as size_t,
            ::core::mem::size_of::<hyperlinks_uri>() as u64,
        )
    }) as *mut hyperlinks_uri;
    let fresh1 = unsafe { (*hl).next_inner };
    (unsafe { (*hl).next_inner = ((*hl).next_inner).wrapping_add(1) });
    (unsafe { (*hlu).inner = fresh1 });
    (unsafe { (*hlu).internal_id = internal_id });
    (unsafe { (*hlu).external_id = external_id });
    (unsafe { (*hlu).uri = uri });
    (unsafe { (*hlu).tree = hl });
    hyperlinks_by_uri_tree_RB_INSERT(unsafe { &mut (*hl).by_uri }, hlu);
    hyperlinks_by_inner_tree_RB_INSERT(unsafe { &mut (*hl).by_inner }, hlu);
    (unsafe { (*hlu).list_entry.tqe_next = std::ptr::null_mut::<hyperlinks_uri>() });
    (unsafe { (*hlu).list_entry.tqe_prev = global_hyperlinks.tqh_last });
    (unsafe { *global_hyperlinks.tqh_last = hlu });
    (unsafe { global_hyperlinks.tqh_last = &mut (*hlu).list_entry.tqe_next });
    (unsafe { global_hyperlinks_count = global_hyperlinks_count.wrapping_add(1) });
    if (unsafe { global_hyperlinks_count }) == 5000 as i32 as u32 {
        hyperlinks_remove(unsafe { global_hyperlinks.tqh_first });
    }
    return unsafe { (*hlu).inner };
}
#[no_mangle]
pub extern "C" fn hyperlinks_get(
    mut hl: *mut hyperlinks,
    mut inner: u_int,
    mut uri_out: *mut *const i8,
    mut internal_id_out: *mut *const i8,
    mut external_id_out: *mut *const i8,
) -> i32 {
    let mut find: hyperlinks_uri = hyperlinks_uri {
        tree: std::ptr::null_mut::<hyperlinks>(),
        inner: 0,
        internal_id: std::ptr::null::<i8>(),
        external_id: std::ptr::null::<i8>(),
        uri: std::ptr::null::<i8>(),
        list_entry: C2RustUnnamed_1 {
            tqe_next: std::ptr::null_mut::<hyperlinks_uri>(),
            tqe_prev: std::ptr::null_mut::<*mut hyperlinks_uri>(),
        },
        by_inner_entry: C2RustUnnamed_0 {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
        by_uri_entry: C2RustUnnamed {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
    };
    let mut hlu: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    find.inner = inner;
    hlu = hyperlinks_by_inner_tree_RB_FIND(unsafe { &mut (*hl).by_inner }, &mut find);
    if hlu.is_null() {
        return 0 as i32;
    }
    if !internal_id_out.is_null() {
        (unsafe { *internal_id_out = (*hlu).internal_id });
    }
    if !external_id_out.is_null() {
        (unsafe { *external_id_out = (*hlu).external_id });
    }
    (unsafe { *uri_out = (*hlu).uri });
    return 1 as i32;
}
#[no_mangle]
pub extern "C" fn hyperlinks_init() -> *mut hyperlinks {
    let mut hl: *mut hyperlinks = std::ptr::null_mut::<hyperlinks>();
    hl = (unsafe {
        xcalloc(
            1 as i32 as size_t,
            ::core::mem::size_of::<hyperlinks>() as u64,
        )
    }) as *mut hyperlinks;
    (unsafe { (*hl).next_inner = 1 as i32 as u_int });
    (unsafe { (*hl).by_uri.rbh_root = std::ptr::null_mut::<hyperlinks_uri>() });
    (unsafe { (*hl).by_inner.rbh_root = std::ptr::null_mut::<hyperlinks_uri>() });
    (unsafe { (*hl).references = 1 as i32 as u_int });
    return hl;
}
#[no_mangle]
pub extern "C" fn hyperlinks_copy(mut hl: *mut hyperlinks) -> *mut hyperlinks {
    (unsafe { (*hl).references = ((*hl).references).wrapping_add(1) });
    return hl;
}
#[no_mangle]
pub extern "C" fn hyperlinks_reset(mut hl: *mut hyperlinks) {
    let mut hlu: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut hlu1: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    hlu = hyperlinks_by_inner_tree_RB_MINMAX(unsafe { &mut (*hl).by_inner }, -(1 as i32));
    while !hlu.is_null() && {
        hlu1 = hyperlinks_by_inner_tree_RB_NEXT(hlu);
        1 as i32 != 0
    } {
        hyperlinks_remove(hlu);
        hlu = hlu1;
    }
}
#[no_mangle]
pub extern "C" fn hyperlinks_free(mut hl: *mut hyperlinks) {
    (unsafe { (*hl).references = ((*hl).references).wrapping_sub(1) });
    if (unsafe { (*hl).references }) == 0 as i32 as u32 {
        hyperlinks_reset(hl);
        (unsafe { free(hl as *mut libc::c_void) });
    }
}
extern "C" fn run_static_initializers() {
    (unsafe {
        global_hyperlinks = {
            let mut init = hyperlinks_list {
                tqh_first: std::ptr::null_mut::<hyperlinks_uri>(),
                tqh_last: &mut global_hyperlinks.tqh_first,
            };
            init
        }
    });
}
#[used]
#[cfg_attr(target_os = "linux", link_section = ".init_array")]
#[cfg_attr(target_os = "windows", link_section = ".CRT$XIB")]
#[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")]
static INIT_ARRAY: [unsafe extern "C" fn(); 1] = [run_static_initializers];
